<%--
  Created by IntelliJ IDEA.
  User: sun
  Date: 2020/5/7
  Time: 3:12 下午
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8"  %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
    <title>员工列表</title>
</head>
<body>
<h1>员工列表</h1>
<table border="1" cellpadding="5" cellspacing="0">
    <tr>
        <th> ID</th>
        <th>LastName</th>
        <th>Email</th>
        <th>Gender</th>
        <th>Department</th>
        <th>Edit</th>
        <th>Delete</th>
    </tr>
    <c:forEach items="${emps}" var="emp">
        <tr>
            <td>${emp.id}</td>
            <td>${emp.lastName}</td>
            <td>${emp.email}</td>
            <td>${emp.gender==0?"女":"男"}</td>
            <td>${emp.department.departmentName}</td>
            <td>${emp.birth}</td>
            <td>${emp.salary}</td>
            <td><a href="${pageContext.request.contextPath}/emp/${emp.id}">edit</a></td>
            <td>
                <form action="${pageContext.request.contextPath}/emp/${emp.id}" method="post">
                    <input type="hidden" name="_method" value="DELETE">
                    <input type="submit" value="delete">
                </form>
            </td>
        </tr>
    </c:forEach>
</table>
<a href="${pageContext.request.contextPath}/toAddPage">添加</a>
<form action="empAdd" method="POST">
<!-- 解决问题：
    1.数据类型转换
    2.数据格式
    3.数据校验                 
    自定义类型转换器：将字符串转换为Employee对象,完成添加功能           
-->
    <!-- 字符串格式：lastName-email-gender-department.id
        例如：GG-gg@atguigu.com-0-105        
     -->
    Employee : <input type="text" name="employee"/>                                
                <input type="submit" value="Submit"><br><br>
</form>
</body>
</html>
